class Solution {
public:
    int findFinalValue(vector<int>& nums, int original) {
        unordered_set<int> unset;
        for (int n : nums) unset.insert(n);
        while (true) {
            if (unset.find(original) == unset.end()) return original;
            original *= 2;
        }
        return original;
    }
};